package com.bd03.streaminglearn.day0328

import org.apache.log4j.{Level, Logger}
import org.apache.spark.SparkConf
import org.apache.spark.streaming.dstream.{DStream, InputDStream}
import org.apache.spark.streaming.{Seconds, StreamingContext}


object StreamingContextDemo {
  def creatingFunc():StreamingContext={
    val conf = new SparkConf().setMaster("local[*]").setAppName(this.getClass.getSimpleName)
    val ssc = new StreamingContext(conf,Seconds(5))

    ssc.checkpoint("mycheckdir")
    val path = "file:///D:\\aaa"
    val data: DStream[String] = ssc.textFileStream(path)

    ssc
  }
  def main(args: Array[String]): Unit = {
    Logger.getLogger("org").setLevel(Level.WARN)
    //SparkContext.getOrCreate()
    val ssc = StreamingContext.getOrCreate("mycheckdir",creatingFunc)

    ssc.start()
    ssc.awaitTermination()
  }

}
